home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / u_man / cat3 / Tcl / dstring.z / dstring
Encoding:
Text File  |  1998-10-30  |  11.8 KB  |  199 lines

  1.  
  2.  
  3.  
  4. TTTTccccllll____DDDDSSSSttttrrrriiiinnnngggg((((3333TTTTccccllll))))                                            TTTTccccllll____DDDDSSSSttttrrrriiiinnnngggg((((3333TTTTccccllll))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Tcl_DStringInit, Tcl_DStringAppend, Tcl_DStringAppendElement,
  10.      Tcl_DStringStartSublist, Tcl_DStringEndSublist, Tcl_DStringLength,
  11.      Tcl_DStringValue, Tcl_DStringSetLength, Tcl_DStringFree,
  12.      Tcl_DStringResult, Tcl_DStringGetResult - manipulate dynamic strings
  13.  
  14. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  15.      ####iiiinnnncccclllluuuuddddeeee <<<<ttttccccllll....hhhh>>>>
  16.  
  17.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggIIIInnnniiiitttt(_d_s_P_t_r)
  18.  
  19.      char *
  20.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggAAAAppppppppeeeennnndddd(_d_s_P_t_r, _s_t_r_i_n_g, _l_e_n_g_t_h)
  21.  
  22.      char *
  23.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggAAAAppppppppeeeennnnddddEEEElllleeeemmmmeeeennnntttt(_d_s_P_t_r, _s_t_r_i_n_g)
  24.  
  25.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggSSSSttttaaaarrrrttttSSSSuuuubbbblllliiiisssstttt(_d_s_P_t_r)
  26.  
  27.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggEEEEnnnnddddSSSSuuuubbbblllliiiisssstttt(_d_s_P_t_r)
  28.  
  29.      int
  30.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggLLLLeeeennnnggggtttthhhh(_d_s_P_t_r)
  31.  
  32.      char *
  33.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggVVVVaaaalllluuuueeee(_d_s_P_t_r)
  34.  
  35.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggSSSSeeeettttLLLLeeeennnnggggtttthhhh(_d_s_P_t_r, _n_e_w_L_e_n_g_t_h)                                   |
  36.  
  37.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee(_d_s_P_t_r)
  38.  
  39.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggRRRReeeessssuuuulllltttt(_i_n_t_e_r_p, _d_s_P_t_r)
  40.  
  41.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggGGGGeeeettttRRRReeeessssuuuulllltttt(_i_n_t_e_r_p, _d_s_P_t_r)                                      |
  42.  
  43. AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
  44.      Tcl_DString   *_d_s_P_t_r      (in/out)  Pointer to structure that is used to
  45.                                          manage a dynamic string.
  46.  
  47.      char          *_s_t_r_i_n_g     (in)      Pointer to characters to add to
  48.                                          dynamic string.
  49.  
  50.      int           _l_e_n_g_t_h      (in)      Number of characters from string to
  51.                                          add to dynamic string.  If -1, add
  52.                                          all characters up to null terminating
  53.                                          character.
  54.  
  55.      int           _n_e_w_L_e_n_g_t_h   (in)      New length for dynamic string, not
  56.                                          including null terminating character.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTccccllll____DDDDSSSSttttrrrriiiinnnngggg((((3333TTTTccccllll))))                                            TTTTccccllll____DDDDSSSSttttrrrriiiinnnngggg((((3333TTTTccccllll))))
  71.  
  72.  
  73.  
  74.      Tcl_Interp    *_i_n_t_e_r_p     (in/out)  Interpreter whose result is to be set
  75.                                          from or moved to the dynamic string.
  76.  
  77.  
  78. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  79.      Dynamic strings provide a mechanism for building up arbitrarily long
  80.      strings by gradually appending information.  If the dynamic string is
  81.      short then there will be no memory allocation overhead;  as the string
  82.      gets larger, additional space will be allocated as needed.
  83.  
  84.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggIIIInnnniiiitttt initializes a dynamic string to zero length.  The
  85.      Tcl_DString structure must have been allocated by the caller.  No
  86.      assumptions are made about the current state of the structure; anything
  87.      already in it is discarded.  If the structure has been used previously,
  88.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee should be called first to free up any memory allocated
  89.      for the old string.
  90.  
  91.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggAAAAppppppppeeeennnndddd adds new information to a dynamic string, allocating
  92.      more memory for the string if needed.  If _l_e_n_g_t_h is less than zero then
  93.      everything in _s_t_r_i_n_g is appended to the dynamic string;  otherwise _l_e_n_g_t_h
  94.      specifies the number of bytes to append.  TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggAAAAppppppppeeeennnndddd returns a
  95.      pointer to the characters of the new string.  The string can also be
  96.      retrieved from the _s_t_r_i_n_g field of the Tcl_DString structure.
  97.  
  98.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggAAAAppppppppeeeennnnddddEEEElllleeeemmmmeeeennnntttt is similar to TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggAAAAppppppppeeeennnndddd except that it
  99.      doesn't take a _l_e_n_g_t_h argument (it appends all of _s_t_r_i_n_g) and it converts
  100.      the string to a proper list element before appending.
  101.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggAAAAppppppppeeeennnnddddEEEElllleeeemmmmeeeennnntttt adds a separator space before the new list
  102.      element unless the new list element is the first in a list or sub-list
  103.      (i.e. either the current string is empty, or it contains the single
  104.      character ``{'', or the last two characters of the current string are ``
  105.      {'').  TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggAAAAppppppppeeeennnnddddEEEElllleeeemmmmeeeennnntttt returns a pointer to the characters of
  106.      the new string.
  107.  
  108.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggSSSSttttaaaarrrrttttSSSSuuuubbbblllliiiisssstttt and TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggEEEEnnnnddddSSSSuuuubbbblllliiiisssstttt can be used to create
  109.      nested lists.  To append a list element that is itself a sublist, first
  110.      call TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggSSSSttttaaaarrrrttttSSSSuuuubbbblllliiiisssstttt, then call TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggAAAAppppppppeeeennnnddddEEEElllleeeemmmmeeeennnntttt for each
  111.      of the elements in the sublist, then call TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggEEEEnnnnddddSSSSuuuubbbblllliiiisssstttt to end
  112.      the sublist.  TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggSSSSttttaaaarrrrttttSSSSuuuubbbblllliiiisssstttt appends a space character if
  113.      needed, followed by an open brace;  TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggEEEEnnnnddddSSSSuuuubbbblllliiiisssstttt appends a close
  114.      brace.  Lists can be nested to any depth.
  115.  
  116.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggLLLLeeeennnnggggtttthhhh is a macro that returns the current length of a dynamic
  117.      string (not including the terminating null character).  TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggVVVVaaaalllluuuueeee
  118.      is a  macro that returns a pointer to the current contents of a dynamic
  119.      string.
  120.  
  121.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggSSSSeeeettttLLLLeeeennnnggggtttthhhh changes the length of a dynamic string.  If         |
  122.      _n_e_w_L_e_n_g_t_h is less than the string's current length, then the string is   |
  123.      truncated.  If _n_e_w_L_e_n_g_t_h is greater than the string's current length,    |
  124.      then the string will become longer and new space will be allocated for   |
  125.      the string if needed.  However, TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggSSSSeeeettttLLLLeeeennnnggggtttthhhh will not initialize |
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. TTTTccccllll____DDDDSSSSttttrrrriiiinnnngggg((((3333TTTTccccllll))))                                            TTTTccccllll____DDDDSSSSttttrrrriiiinnnngggg((((3333TTTTccccllll))))
  137.  
  138.  
  139.  
  140.      the new space except to provide a terminating null character;  it is up  |
  141.      to the caller to fill in the new space.  TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggSSSSeeeettttLLLLeeeennnnggggtttthhhh does not   |
  142.      free up the string's storage space even if the string is truncated to    |
  143.      zero length, so TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee will still need to be called.
  144.  
  145.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee should be called when you're finished using the string.
  146.      It frees up any memory that was allocated for the string and
  147.      reinitializes the string's value to an empty string.
  148.  
  149.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggRRRReeeessssuuuulllltttt sets the result of _i_n_t_e_r_p to the value of the dynamic
  150.      string given by _d_s_P_t_r.  It does this by moving a pointer from _d_s_P_t_r to
  151.      _i_n_t_e_r_p->_r_e_s_u_l_t.  This saves the cost of allocating new memory and copying
  152.      the string.  TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggRRRReeeessssuuuulllltttt also reinitializes the dynamic string to
  153.      an empty string.
  154.  
  155.      TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggGGGGeeeettttRRRReeeessssuuuulllltttt does the opposite of TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggRRRReeeessssuuuulllltttt.  It sets the|
  156.      value of _d_s_P_t_r to the result of _i_n_t_e_r_p and it clears _i_n_t_e_r_p's result.  If|
  157.      possible it does this by moving a pointer rather than by copying the     |
  158.      string.
  159.  
  160.  
  161. KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  162.      append, dynamic string, free, result
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.